home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u283.dms / u283.adf / replay2b.asm < prev    next >
Assembly Source File  |  1995-07-23  |  9KB  |  553 lines

  1.     section    Sfx,code_c
  2.     opt    c-
  3.  
  4. ; ©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
  5. ; © Sound FX 1.8 replay - NO INTERRUPT - Devpac ][. ©
  6. ; ©   Coded by Kerni of Magnetic Fields (C) 1991.   ©
  7. ; ©     RASTER TIME = $2c-$40 (21 raster lines)     ©      
  8. ; ©-------------------------------------------------©
  9. ; ©This player was rewritten so that it can be used ©
  10. ; © in demos by calling it each frame as with the   ©
  11. ; ©  Noisetracker & Soundtracker replay routines    ©
  12. ; © The original version ran under a lev6 interrupt ©
  13. ; © (!) this version needs the following info....   ©
  14. ; © Speed of Song: Change 'Speed' to speed of song  ©
  15. ; © call 'SfxStart' once, 'SfxPlay' every frame and ©
  16. ; © 'SfxStop' to end music, Datas at 'SfxDatas' !!  © 
  17. ; ©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
  18.  
  19.     bsr    SfxStart
  20. Test:    ;move.l    $dff004,d2
  21.     ;and.l    #$0001ff00,d2
  22.     ;cmp.l    #$00001000,d2
  23.     ;bne.s    Test
  24.     cmp.b    #200,$dff006
  25.     bne.s    test
  26. ;    move.w    #$00f,$dff180    
  27.     bsr    SfxPlay
  28. ;    move.w    #$000,$dff180
  29.  
  30. Mouse:    btst    #6,$bfe001
  31.     bne    Test
  32. End:    bsr    SfxStop
  33.     bclr    #1,$bfe001
  34.  
  35.     moveq    #0,d0
  36.     rts
  37.  
  38. SfxStart:
  39.     bset    #1,$bfe001
  40. ;    move.l    4,a6            
  41. ;    move.l    SongPointer,a1    
  42. ;    jsr    -534(A6)        
  43. ;    move.l    #SfxDatas,d0        
  44. ;    addq.l    #4,d0            
  45. ;    moveq    #2,d1            
  46. ;    jsr    -198(a6)        
  47.     moveq    #-1,d5            
  48.     move.l    d0,a1            
  49.     move.l    Songpointer,a0    
  50.     move.l    #SfxDatas,d1
  51.     addq.l    #4,d1            
  52.     lsr.l    #2,d1            
  53.     subq    #1,d1            
  54.     move.l    SongPointer,a0    
  55.     add    #60,a0            
  56.     move.b    470(a0),AnzPat+1    
  57.     move    4(A0),DelayValue     
  58.     bsr    SongLen            
  59.     add.l    d0,a0            
  60.     add.w    #600,a0            
  61.     move.l    SongPointer,a2
  62.     lea    Instruments,a1    
  63.     moveq    #14,d7            
  64. CalcIns:
  65.     move.l    a0,(A1)+        
  66.     add.l    (a2)+,a0        
  67.     dbf    d7,CalcIns
  68. ;    lea    CiaaResource,a1    
  69. ;    moveq    #0,d0            
  70. ;    jsr    -498(A6)        
  71. ;    move.l    d0,CiaaBase        
  72. ;    move.l    d0,a6
  73.     jsr    PlayDisable        
  74.     jsr    PlayInit        
  75.     jsr    PlayEnable        
  76.     jsr    InitTimer        
  77.     rts
  78. SfxPlay:                
  79.     movem.l    d0-d7/a0-a6,-(SP)
  80.     addq.w    #1,Timer        
  81. ;    move.w    speed,d7
  82.     cmp.w    #speed,Timer
  83.     bne    CheckEffects        
  84.     clr.w    Timer            
  85.     bsr     PlaySound        
  86.     movem.l    (SP)+,d0-d7/a0-a6
  87.     rts
  88. SfxStop:
  89.     clr.l    $dff0a8
  90.     clr.l    $dff0b8
  91.     clr.l    $dff0c8
  92.     clr.l    $dff0d8
  93.     rts
  94. SongLen:
  95.     movem.l    d1-d7/a0-a6,-(SP)
  96.     move.l    SongPointer,a0
  97.     lea    532(A0),a0
  98.     move    AnzPat(pc),d2        
  99.     subq    #1,d2            
  100.     moveq    #0,d1
  101.     moveq    #0,d0
  102. SongLenLoop:
  103.     move.b    (a0)+,d0        
  104.     cmp.b    d0,d1            
  105.     bhi.s    LenHigher        
  106.     move.b    d0,d1        
  107. LenHigher:
  108.     dbf    d2,SongLenLoop
  109.     move.l    d1,d0            
  110.     addq    #1,d0            
  111.     mulu    #1024,d0        
  112.     movem.l    (SP)+,d1-d7/a0-a6
  113.     rts
  114. InitTimer:
  115. ;    move.b    #%10000001,$bfee01    
  116. ;    lea    DelayValue(pc),a1
  117. ;    move.b    1(a1),$bfe401        
  118. ;    move.b    0(a1),$bfe501        
  119.     rts
  120. PlayInit:
  121.     lea    Instruments(pc),a0    
  122.     moveq    #14,d7            
  123. InitLoop:    
  124.     move.l    (A0)+,a1        
  125.     clr.l    (A1)            
  126.     dbf    d7,InitLoop
  127.     rts
  128. PlayEnable:
  129.     lea    $dff000,a0        
  130.     move.w    #-1,PlayLock        
  131.     clr    $a8(A0)            
  132.     clr    $b8(A0)
  133.     clr    $c8(a0)
  134.     clr    $d8(a0)
  135.     clr.w    Timer            
  136.     clr.l    TrackPos        
  137.     clr.l    PosCounter        
  138.     rts
  139. PlayDisable:
  140.     lea    $dff000,a0        
  141.     clr.w    PlayLock        
  142.     clr    $a8(a0)            
  143.     clr    $b8(a0)
  144.     clr    $c8(a0)
  145.     clr    $d8(a0)
  146.     move.w    #$f,$96(A0)        
  147.     rts
  148. IntCode:
  149.     bsr    SfxPlay        
  150.     moveq    #0,d0            
  151.     rts
  152. CheckEffects:
  153.     moveq    #3,d7            
  154.     lea    StepControl0,a4
  155.     lea    Channel0(pc),a6    
  156.     lea    $dff0a0,a5        
  157. EffLoop:
  158.     movem.l    d7/a5,-(SP)
  159.     bsr.s    MakeEffects        
  160.     movem.l    (Sp)+,d7/a5
  161. NoEff:
  162.     add    #8,a4
  163.     add    #$10,a5            
  164.     add    #22,a6            
  165.     dbf    d7,EffLoop
  166.     movem.l    (a7)+,d0-d7/a0-a6
  167.     rts
  168. MakeEffects:
  169.     move    (A4),d0
  170.     beq.s    NoStep
  171.     bmi.s    StepItUp
  172.     add    d0,2(A4)
  173.     move    2(A4),d0
  174.     move    4(A4),d1
  175.     cmp    d0,d1
  176.     bhi.s    StepOk
  177.     move    d1,d0
  178. StepOk:
  179.     move    d0,6(a5)
  180.     move    D0,2(A4)
  181.     rts
  182. StepItUp:
  183.     add    d0,2(A4)
  184.     move    2(A4),d0
  185.     move    4(A4),d1
  186.     cmp    d0,d1
  187.     blt.s    StepOk
  188.     move    d1,d0
  189.     bra.s    StepOk
  190. NoStep:
  191.     move.b    2(a6),d0
  192.     and.b    #$0f,d0
  193.     cmp.b    #1,d0
  194.     beq    Arpeggio
  195.     cmp.b    #2,d0
  196.     beq    pitchbend
  197.     cmp.b    #7,d0
  198.     beq.s    SetStepUp
  199.     cmp.b    #8,d0
  200.     beq.s    SetStepDown
  201.     rts
  202. SetStepUp:
  203.     moveq    #0,d4
  204. StepFinder:
  205.     clr    (a4)
  206.     move    (A6),2(a4)
  207.     moveq    #0,d2
  208.     move.b    3(a6),d2
  209.     and    #$0f,d2
  210.     tst    d4
  211.     beq.s    NoNegIt
  212.     neg    d2
  213. NoNegIt:    
  214.     move    d2,(a4)
  215.     moveq    #0,d2
  216.     move.b    3(a6),d2
  217.     lsr    #4,d2
  218.     move    (a6),d0
  219.     lea    NoteTable,a0
  220. StepUpFindLoop:
  221.     move    (A0),d1
  222.     cmp    #-1,d1
  223.     beq.s    EndStepUpFind
  224.     cmp    d1,d0
  225.     beq.s    StepUpFound
  226.     addq    #2,a0
  227.     bra.s    StepUpFindLoop
  228. StepUpFound:
  229.     lsl    #1,d2
  230.     tst    d4
  231.     bne.s    NoNegStep
  232.     neg    d2
  233. NoNegStep:
  234.     move    (a0,d2.w),d0
  235.     move    d0,4(A4)
  236.     rts
  237. EndStepUpFind:
  238.     move    d0,4(A4)
  239.     rts
  240. SetStepDown:
  241.     st    d4
  242.     bra.s    StepFinder
  243. StepControl0:
  244.     dc.l    0,0
  245. StepControl1:
  246.     dc.l    0,0
  247. StepControl2:
  248.     dc.l    0,0
  249. StepControl3:
  250.     dc.l    0,0
  251. Arpeggio:
  252.     lea    ArpeTable,a0
  253.     moveq    #0,d0
  254.     move    Timer,d0
  255.     subq    #1,d0
  256.     lsl    #2,d0
  257.     move.l    (A0,d0.l),a0
  258.     jmp    (A0)
  259. Arpe4:    lsl.l    #1,d0
  260.     clr.l    d1
  261.     move.w    16(a6),d1
  262.     lea.l    NoteTable,a0
  263. Arpe5:    move.w    (a0,d0.l),d2
  264.     cmp.w    (a0),d1
  265.     beq.s    Arpe6
  266.     addq.l    #2,a0
  267.     bra.s    Arpe5
  268. Arpe1:    clr.l    d0
  269.     move.b    3(a6),d0
  270.     lsr.b    #4,d0
  271.     bra.s    Arpe4
  272. Arpe2:    clr.l    d0
  273.     move.b    3(a6),d0
  274.     and.b    #$0f,d0
  275.     bra.s    Arpe4
  276. Arpe3:    move.w    16(a6),d2
  277. Arpe6:    move.w    d2,6(a5)
  278.     rts
  279. Pitchbend:
  280.     clr.l    d0
  281.     move.b    3(a6),d0
  282.     lsr.b    #4,d0
  283.     tst.b    d0
  284.     beq.s    pitch2
  285.     add.w    d0,(a6)
  286.     move.w    (a6),6(a5)
  287.     rts
  288. Pitch2:    clr.l    d0
  289.     move.b    3(a6),d0
  290.     and.b    #$0f,d0
  291.     tst.b    d0
  292.     beq.s    pitch3
  293.     sub.w    d0,(a6)
  294.     move.w    (a6),6(a5)
  295. Pitch3:    rts
  296.  
  297.  
  298.  
  299. PlaySound:
  300.     move.l    SongPointer(pc),a0    
  301.     add    #60,a0            
  302.     move.l    a0,a3
  303.     move.l    a0,a2
  304.     lea    600(A0),a0        
  305.     add    #472,a2            
  306.     add    #12,a3            
  307.     move.l    TrackPos(pc),d0        
  308.     clr.l    d1
  309.     move.b    (a2,d0.l),d1        
  310.     moveq    #10,d7
  311.     lsl.l    d7,d1            
  312.     add.l    PosCounter,d1        
  313.     clr.w    DmaCon
  314.     lea    StepControl0,a4
  315.     lea    $dff0a0,a5        
  316.     lea    Channel0(pc),a6    
  317.     moveq    #3,d7            
  318.     lea    datas(pc),a2
  319. SoundHandleLoop:
  320.     bsr    PlayNote
  321.     add    #8,a4
  322.     add.l    #$10,a5
  323.     add.l    #22,a6
  324.     dbf    d7,SoundHandleLoop
  325.  
  326.     lea    datas(pc),a2
  327.     lea    equals(pc),a3
  328.     move.l    #0,(a3)
  329.     move.l    #0,4(a3)
  330.     move.w    #3,d7
  331. Dowot:
  332.     move.l    (a2)+,a5
  333.     move.l    (a2)+,a6
  334.  
  335.  
  336.     cmp.l    #dummyarea,a5
  337.     beq.s    OobyDooby
  338.     move.w    (a2),(a3)
  339. OobyDooby:
  340.     addq.w    #2,a2
  341.     addq.w    #2,a3
  342.  
  343.     cmp    #-2,(A6)        
  344.     bne.s    NoStop            
  345.     clr    8(A5)
  346.     bra    Super
  347. NoStop:
  348.     move.l    4(a6),0(a5)        
  349.     move.w    8(a6),4(a5)        
  350.     move.w    0(a6),6(a5)        
  351. Super:
  352.     move.w    20(a6),d0        
  353.     or.w    d0,DmaCon        
  354.  
  355.     dbf    d7,dowot
  356.  
  357.     move    DmaCon(pc),d0        
  358.     bset    #15,d0            
  359.     move.w    d0,$dff096        
  360.  
  361.  
  362.     move    #50,d0                    *******300
  363. Delay2:
  364.     dbf    d0,Delay2
  365.  
  366.     lea    Channel3(pc),a6
  367.     lea    $dff0d0,a5
  368.     moveq    #3,d7
  369. SetRegsLoop:
  370.     move.l    10(A6),(a5)        
  371.     move    14(A6),4(A5)        
  372. NoSetRegs:
  373.     sub    #22,a6            
  374.     sub    #$10,a5            
  375.     dbf    d7,SetRegsLoop
  376.     tst    PlayLock
  377.     beq.s    NoEndPattern
  378.     add.l    #16,PosCounter        
  379.     cmp.l    #1024,PosCounter    
  380.     blt.s    NoEndPattern
  381.     clr.l    PosCounter        
  382.     addq.l    #1,TrackPos        
  383. NoAddPos:
  384.     move.w    Anzpat(pc),d0        
  385.     move.l    TrackPos(pc),d1        
  386.     cmp.w    d0,d1            
  387.     bne.s    NoEndPattern        
  388.     clr.l    TrackPos        
  389. NoEndPattern:
  390.     rts
  391.  
  392. datas:    dc.l    0,0
  393.     dc.w    0
  394.     dc.l    0,0
  395.     dc.w    0
  396.     dc.l    0,0
  397.     dc.w    0
  398.     dc.l    0,0
  399.     dc.w    0
  400. equals:    dc.w    0,0,0,0
  401.  
  402.  
  403.  
  404. PlayNote:
  405.     clr.l    (A6)
  406.     tst    PlayLock        
  407.     beq    NoGetNote        
  408.     move.l    (a0,d1.l),(a6)        
  409. NoGetNote:
  410.     addq.l    #4,d1            
  411.     clr.l    d2
  412.     cmp    #-3,(A6)        
  413.     beq    NoInstr2        
  414.     move.b    2(a6),d2            
  415.     and.b    #$f0,d2            
  416.     lsr.b    #4,d2            
  417.     tst.b    d2            
  418.     beq    NoInstr2            
  419.     clr.l    d3
  420.     lea.l    Instruments(pc),a1    
  421.     move.l    d2,d4            
  422.     subq    #1,d2
  423.     lsl    #2,d2            
  424.     mulu    #30,d4            
  425.     move.l    (a1,d2.w),4(a6)        
  426.     move.w    (a3,d4.l),8(a6)        
  427.     move.w    2(a3,d4.l),18(a6)    
  428.     move.w    4(a3,d4.l),d3        
  429.     tst    d3            
  430.     beq.s    NoRepeat                                
  431.     move.l    4(a6),d2        
  432.     add.l    d3,d2            
  433.     move.l    d2,10(a6)        
  434.     move.w    6(a3,d4),14(a6)        
  435.     move.w    18(a6),d3         
  436.     bra.s    NoInstr
  437. NoRepeat:
  438.     move.l    4(a6),d2            
  439.     add.l    d3,d2            
  440.     move.l    d2,10(a6)        
  441.     move.w    6(a3,d4.l),14(a6)    
  442.     move.w    18(a6),d3         
  443. NoInstr:
  444.     move.b    2(A6),d2
  445.     and    #$0f,d2
  446.     cmp.b    #5,d2
  447.     beq.s    ChangeUpVolume
  448.     cmp.b    #6,d2
  449.     bne    SetVolume2
  450.     moveq    #0,d2
  451.     move.b    3(A6),d2
  452.     sub    d2,d3        
  453.     tst    d3
  454.     bpl    SetVolume2    
  455.     clr    d3
  456.     bra    SetVolume2
  457. ChangeUpVolume:
  458.     moveq    #0,d2
  459.     move.b    3(A6),d2
  460.     add    d2,d3
  461.     tst    d3
  462.     cmp    #64,d3
  463.     ble    SetVolume2
  464.     move    #64,d3
  465. SetVolume2:
  466.     move    d3,8(A5)
  467. NoInstr2:
  468.     cmp    #-3,(A6)        
  469.     bne.s    NoPic        
  470.     clr    2(A6)            
  471.     bra.s    NoNote    
  472. NoPic:
  473.     tst    (A6)            
  474.     beq.s    NoNote            
  475.     clr    (a4)
  476.     move.w    (a6),16(a6)        
  477.     move.w    20(a6),$dff096        
  478.  
  479. ;    move    #50,d7                *********300
  480. ;Delay1:
  481. ;    dbf    d7,Delay1        
  482.  
  483.     move.l    a5,(a2)+
  484.     move.l    a6,(a2)+
  485.     move.w    d3,(a2)+
  486.     rts
  487. NoNote:
  488.     move.l    #dummyarea,(a2)+
  489.     move.l    #dummyarea,(a2)+
  490.     move.w    d3,(a2)+
  491.     rts
  492.  
  493. dummyarea:
  494.     dcb.l    100,0
  495.  
  496. ArpeTable:
  497.     dc.l    Arpe1
  498.     dc.l    Arpe2
  499.     dc.l    Arpe3
  500.     dc.l    Arpe2
  501.     dc.l    Arpe1
  502. Channel0:
  503.     dcb.l    5,0            
  504.     dc.w    1            
  505. Channel1:    
  506.     dcb.l    5,0            
  507.     dc.w    2
  508. Channel2:    
  509.     dcb.l    5,0            
  510.     dc.w    4
  511. Channel3:    
  512.     dcb.l    5,0            
  513.     dc.w    8
  514. Instruments:
  515.     dcb.l    15,0            
  516. PosCounter:
  517.     dc.l    0            
  518. TrackPos:
  519.     dc.l    0            
  520. Timer:
  521.     dc.w    0            
  522. DmaCon:
  523.     dc.w    0            
  524. AnzPat:
  525.     dc.w    1            
  526. PlayLock:
  527.     dc.w    0            
  528. DelayValue:
  529.     dc.w    14565
  530. SongPointer:
  531.     dc.l    LenghtTable
  532. Reserve:
  533.     dc.w    856,856,856,856,856,856,856,856,856,856,856,856
  534. NoteTable:
  535.     dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  536.       dc.w    428,404,381,360,339,320,302,285,269,254,240,226   
  537.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113      
  538.     dc.w    113,113,113,113,113,113,113,113,113,113,113,113      
  539.     dc.w    -1
  540.  
  541. LenghtTable:
  542.  
  543. Songstr equ lenghttable+60
  544.  
  545. Speed:    equ    6
  546.  
  547. SfxDatas:
  548.  
  549.     incbin    "df0:sfx.cubik(loudremix)"
  550.     even
  551.     
  552.  
  553.